package top.mollysu.sell.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import top.mollysu.sell.enums.ProductStatusEnum;
import top.mollysu.sell.util.EnumUtil;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品
 */
@Entity
@Data
@DynamicUpdate
@DynamicInsert
public class ProductInfo {

    @Id
    private String productId;

    /** 名字 */
    private String productName;

    /** 单价 */
    private BigDecimal productPrice;

    /** 库存 */
    private Integer productStock;

    /** 描述 */
    private String productDescription;

    /** 小图 */
    private String productIcon;

    /** 状态*/
    private Integer productStatus;

    /** 类目编号*/
    private Integer categoryType;

    private Date createTime;

    private Date updateTime;

    @JSONField(serialize = false)
    public ProductStatusEnum getProductStatusEnum() {
        return EnumUtil.getcode(productStatus, ProductStatusEnum.class);
    }

}
